/*
 * OperatorBasedNeighbourhood.h
 *
 *  Created on: Jan 16, 2011
 *      Author: LyonsDesktop
 */

#ifndef OPERATORBASEDNEIGHBOURHOOD_H_
#define OPERATORBASEDNEIGHBOURHOOD_H_

#include "Neighbourhood.h"

#include <vector>

namespace CLEVER {
namespace RegionDiscovery {
class OperatorBasedNeighbourhood : public Neighbourhood
{
public:
	enum Operator {
		OP_Insert = 0,
		OP_Replace = 1,
		OP_Delete = 2
	};

	std::vector<std::vector<int> > FindNeighbours(std::vector<int> & CurReps, std::vector<int> & NonReps, int p);

	bool CheckParameters(std::vector<int> & CurReps, std::vector<int> & NonReps, int p);

	//! Check if any values on this list are not unique
	bool IsRedundancy(std::vector<int> & rlist);

	std::vector<int> Insert(std::vector<int> & CurReps, std::vector<int> & NonReps);

	std::vector<int> Delete(std::vector<int> & CurReps, std::vector<int> & NonReps);

	std::vector<int> Replace(std::vector<int> & CurReps, std::vector<int> & NonReps);

	//! Select a random operator given the set of probabilities
	Operator SelectOperator(std::vector<Operator> & ops, std::vector<double> & op_prob);

	//! Validate that the sum of the probabilities equal 1.
	bool CheckValidProbs(std::vector<double> & op_prob);

	//! Validate the operators
	bool CheckValidOps(std::vector<Operator> & ops);

	//! Constructor
	/*!
	   \param ops Operations
	   \param op_prob Probability of operation
	   \param neighbourhood_size Neighbourhood size
	 */
	OperatorBasedNeighbourhood(std::vector<Operator> & ops, std::vector<double> & op_prob, int neighbourhood_size);

private:
	std::vector<Operator> ops;
	std::vector<double> op_prob;
	int neighbourhood_size;
};
}
}

#endif /* OPERATORBASEDNEIGHBOURHOOD_H_ */
